#include <bitset>
#include <gtest/gtest.h>
class SolveStatus : public std::bitset<4>
{
public:
  void succes()
  {
    this->set(SUCCES_BIT);
    this->set(FINISHED_BIT);
  }
  void error()
  {
    this->reset(SUCCES_BIT);
    this->set(ERROR_BIT);
    this->reset(FINISHED_BIT);
  }
  void finished()
  {
    this->set(SUCCES_BIT);
    this->reset(ERROR_BIT);
    this->set(FINISHED_BIT);
  }

  bool is_succes() { return this->test(SUCCES_BIT); }
  bool is_error() { return this->test(ERROR_BIT); }
  bool is_finished() { return this->test(FINISHED_BIT); }

private:
  static constexpr unsigned int SUCCES_BIT = 0;
  static constexpr unsigned int ERROR_BIT = 1;
  static constexpr unsigned int FINISHED_BIT = 2;
};

namespace std
{
//ostream;
}

inline std::ostream& operator<<(std::ostream& os, const SolveStatus& status)
{
  os << status.to_string();
  return os;
}

TEST(std, bitset)
{
  std::bitset<4> bset;
  EXPECT_EQ(bset.to_string(), "0000");
  EXPECT_EQ(bset[0], false);
  bset[0] = true;
  EXPECT_EQ(bset[0], true);
  EXPECT_EQ(bset.to_string(), "0001");

  bset.set();
  EXPECT_EQ(bset.to_string(), "1111");

  bset.reset();
  EXPECT_EQ(bset.to_string(), "0000");

  bset.set(1);
  EXPECT_EQ(bset.to_string(), "0010");

  bset.set(1, false);
  EXPECT_EQ(bset.to_string(), "0000");

  bset.set(2);
  EXPECT_EQ(bset.test(0), false);
  EXPECT_EQ(bset.test(1), false);
  EXPECT_EQ(bset.test(2), true);
  EXPECT_EQ(bset.test(3), false);

  SolveStatus status;
  EXPECT_EQ(status.is_succes(), false);

  status.succes();
  EXPECT_EQ(status.is_succes(), true);
  EXPECT_EQ(status.is_finished(), true);

  status.error();
  EXPECT_EQ(status.is_succes(), false);
  EXPECT_EQ(status.is_error(), true);

  []() { EXPECT_EQ(1, 1); }();
}